const {querySql, queryOne} = require('../db')

function getPosData(roleId) {
    let sql = `select *
               from pos
               where del_flag = 0 `;
    if (parseInt(roleId) !== 1) {
        sql += `and roleId=${roleId}`;
    }
    return querySql(sql);
}

function getRolePosById(roleId, id) {
    let sql = `select *
               from pos
               where del_flag = 0
                 and id = ${id} `;
    if (parseInt(roleId) !== 1) {
        sql += `and roleId=${roleId}`;
    }
    return queryOne(sql)
}

module.exports = {
    getPosData,
    getRolePosById
}